<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0" />
    <title>美策平台</title>
    <link rel="icon" type="image/png" href="/img/icon.png">
    <link rel="stylesheet" type="text/css" href="../../datepicker/jquery-ui.min.css">
    <link rel="stylesheet" type="text/css" href="../../css/app.css">
    <link rel="stylesheet" type="text/css" href="../../css/my.css">
    <script type="text/javascript" src="../../js/jquery.min.js"></script>
    <script type="text/javascript" src="/pc/js/all.js"></script>
    <style>
        #accountPage .myTable ul {
            padding:0 10px;
            height:45px;
            border-bottom:1px solid #f5f5f5;
            clear:both;
        }
        #accountPage .myTable li {
            padding:10px 5px;
            list-style:none;
            color:#555555;
            font-size:16px;
            font-weight:bolder;
            float:left;
        }
        #accountPage .myTable li img {
            padding:0 5px;
            padding-right:0px;
            height:22px;
        }
        #accountPage .myTable li.checked {
            color:greenyellow;
            float:right;
        }
        #accountPage a{
            height:56px;color:#535D72;
        }
        .acc-form {
            padding:5px 10px;
            background:#ffffff;
        }
        .acc-form p {
            padding:10px;
            font-size:14px;
        }
        .acc-form input {
            margin:10px 5%;
            padding:5px 0;
            width:90%;
            border-bottom:1px solid #f0f0f0;
            font-size:20px;
        }
        .acc-form .small {
            padding-top:0;
            color:#888888;
            font-size:12px;
        }
        .acc-form .btn {
            margin:10px auto;
            text-align:center;
        }
        .acc-form button {
            padding:10px 20px;
            color:#fefefe;
            font-size:20px;
            border:0;
            border-radius:2px;
            background-image:-webkit-linear-gradient(left , #589cff, #3360fa);
            background-image:-o-linear-gradient(left , #589cff, #3360fa);
            background-image:linear-gradient(left , #589cff, #3360fa);
            cursor:pointer;
        }
        #accountTitle .history {
            padding:10px;
            text-decoration:none;
            color:#3333333;
            position:absolute;top:0;right:0;
        }
    </style>
</head>
<body>
<!--
    制作者：九哥
    页面：我的账户-充值
    时间：2019-07-29
-->





<!----------我的账户充值---------->
<div id="accountPage">
    <div id="accountTitle">
        <b>我的账户-充值</b>
        <img src="../../images/return.png" id="accountRtn">
        <a href="history.html?type=income" class="history">账单</a>
    </div>
    <div class="myTable">
        <ul>
            <li>
                <img src="/h5/images/acc-icon-zfb.png" height="25">
            </li>
            <li>支付宝</li>
            <li class="checked">√</li>
        </ul>
        <ul>
            <li>
                <img src="/h5/images/acc-icon-wx.png" height="25" style="opacity:0.2;">
            </li>
            <li style="color:#f0f0f0;">微信</li>
            <li></li>
        </ul>
    </div>
    <div style="height:15px;"></div>
    <div class="acc-form">
        <p>充值金额(元)：</p>
        <input type="text" placeholder="请输入充值金额" id="income" value="">
        <p class="small">
            最低充值金额为0.1元
        </p>
        <p class="btn">
            <button onclick="makeIncome()">确定充值</button>
        </p>
    </div>
</div>
<div  id="zfb"></div>
<!----------我的账户充值---------->





<!----------错误提示---------->
<div id="errMsg"></div>
<!----------错误提示---------->
</body>
<script type="text/javascript" src="../../js/app.js"></script>
<script type="text/javascript" src="../../js/cache.js"></script>
<script type="text/javascript" src="../../js/mysetPageChange.js"></script>
<script type="text/javascript" src="../../js/myset2.js"></script>
</html>

<script>
    /**
     * 充值
     * */
    function makeIncome(){
        var money = $('#income').val();
        var userInfo = cacheGet('userInfo'); //获取用户信息
        if (userInfo==null || userInfo.token=='undefined') {
            window.location.href = '/h5/login/login.html';
        }
        if (money==null || money=='' || money==0) {
            getAppErrMsg('充值金额未填写！','',0);
            return
        }
        if (money<0.1) {
            getAppErrMsg('充值金额不能小于0.1元！','',0);
            return
        }
        var formData = {
            app_access:app_access,
            token:userInfo.token,
            type:userInfo.type,
            cate:userInfo.cate,
            money:money
        };
        $.ajax({
            type: 'post',
            url: getDomain() + 'income',
            data: formData,
            success: function(res){
                //console.log(res); return;
                if (res.code!=0) {
                    console.log(res.msg);
                    window.location.href = '/h5/my/account/inError.html';
                    return
                }
                var resData = res.data;
                $('#zfb').html(resData.aliForm);
                //数据缓存到本地
                var incomeObj = {
                    serial:resData.params.serial,
                    money:money
                };
                cacheSet('accountIncome',incomeObj);
            },
            error: function(){
                console.log('操作失败！'); return;
            }
        });
    }
    /**
     * 地址前缀
     * */
    function getDomain(){
        return '/api/my/account/';
    }
</script>